package com.xy.job.admin.repository

import com.xy.job.admin.domain.NodeRegistry
import com.xy.job.admin.enums.NodeType
import org.springframework.data.jpa.repository.JpaRepository
import java.time.LocalDateTime

interface NodeRegistryRepository : JpaRepository<NodeRegistry, Long> {
    fun findByNodeType(nodeType: NodeType): List<NodeRegistry>

    fun findByNodeAddress(nodeAddress: String): Iterable<NodeRegistry>

    fun findByLastHeartbeatTimeLessThan(lastHeartbeatTime: LocalDateTime): Iterable<NodeRegistry>

    fun findByNodeTypeAndLastHeartbeatTimeGreaterThan(nodeType: NodeType, lastHeartbeatTime: LocalDateTime): Iterable<NodeRegistry>

    fun findByNodeNameAndNodeTypeAndNodeAddress(
        nodeName: String,
        nodeType: NodeType,
        nodeAddress: String
    ): NodeRegistry?

    fun findByNodeNameAndNodeType(nodeName: String, nodeType: NodeType): List<NodeRegistry>
}